test(typia): cover boolean-literal discriminant in tagged unions#1876
Open
hexbinoct wants to merge 1 commit into
Open
test(typia): cover boolean-literal discriminant in tagged unions#1876hexbinoct wants to merge 1 commit into
hexbinoct wants to merge 1 commit into
Conversation
Adds reflect.schema regression coverage for a boolean-literal discriminant (`ok: false | true`) in a tagged union. The existing test_reflect_schema_constant only exercises a bare `<true>` literal, so a regression that defaulted or mis-compared the literal value could collapse a union's `false` branch onto `true` (breaking discriminated-union narrowing) without any test going red. The new case reflects a bare `<false>` literal and the discriminated union from samchon#1841, then asserts both `false` and `true` survive across the union's branch objects. Refs samchon#1841
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
While looking into #1841 (a boolean-literal discriminant reportedly collapsing to a single value), I checked the current
reflect.schemaoutput and the metadata is correct — but our test suite doesn't actually pin that behavior.test_reflect_schema_constantonly exercises a bare<true>literal; there is no coverage for<false>nor for a boolean-keyed discriminated union.This adds that missing regression coverage so a future change can't silently collapse a union's
falsebranch ontotrue(which would break discriminated-union narrowing) without a test going red.What it checks
falseliteral reflects to abooleanconstant with valuefalsefalseandtrueacross its branch objects:Test
test_reflect_schema_boolean_literal_unionfollows the existingreflect.schemasuite shape (one case per file,TestValidator).pnpm run buildpasses locally; the reflected output for the new case was verified to contain both branch values ([false, true]).Refs #1841